

package examples.basic;

import commandz.cli.*;
import commandz.var.*;
import java.util.Collection;


/**
 *  Makes a new alias for a command.
 */
public class AliasCommand implements Command
{
    private final String COMMAND_NAME = "alias";
    private final String COMMAND_DESCRIPTION = "Makes an alias for a command.";

    protected Interpreter interpreter;
    protected VariableString pseudonym;
    protected VariableString identifier;


    public AliasCommand(final Interpreter interpreter)
    {
        this.interpreter = interpreter;
        this.pseudonym = new VariableString();
        this.identifier = new VariableString();
    }


    public String getName()
    {
        return this.COMMAND_NAME;
    }


    public String getDescription()
    {
        return this.COMMAND_DESCRIPTION;
    }


    public void publishParameters(Collection<Parameter> params)
    {
        params.add(new Parameter(this.pseudonym, "pseudonym", "The pseudonym to use for a command."));
        params.add(new Parameter(this.identifier, "identifier", "The name of an existing command."));
    }


    public void execute()
    {
        this.interpreter.recognize(this.identifier.getValue(), this.pseudonym.getValue());
    }
}
